package common

import (
	"github.com/allegro/bigcache"
	"github.com/astaxie/beego"
	"strconv"
	"time"
)

var (
	PORT = beego.AppConfig.String("httpport")

	MYSQLCONN = beego.AppConfig.String("mysqlconnstr") + beego.AppConfig.String("mysqlconnparam")

	URL_PRE           = beego.AppConfig.String("url_pre")
	UPLOAD_PATH       = beego.AppConfig.String("upload_path")
	SHORT_UPLOAD_PATH = beego.AppConfig.String("short_upload_path")
	SQLMAPPATH        = beego.AppConfig.String("sqlmappath")
	SQLMAPEXT         = beego.AppConfig.String("sqlmapext")
	SQLTEMPLATEPATH   = beego.AppConfig.String("sqltemplatepath")
	SQLTEMPLATEEXT    = beego.AppConfig.String("sqltemplateext")

	TEMPPATH = beego.AppConfig.String("temppath")
	DISTPATH = beego.AppConfig.String("distpath")

	DOWNLOAD_PRE_URL  = beego.AppConfig.String("download_pre_url")
	DOWNLOAD_FILEPATH = beego.AppConfig.String("download_filepath")

	PREFIX_URL       = beego.AppConfig.String("prefix_url")
	EASYWEB_FILEPATH = beego.AppConfig.String("easyweb_filepath")

	//TEMPPATH = "/Users/nagatyase/dmhtest/dmhserver/temp/"
	//DISTPATH = "/Users/nagatyase/dmhtest/dmhserver/dist/"
	//
	//DOWNLOAD_PRE_URL  = "http://localhost:7221/"
	//DOWNLOAD_FILEPATH = "/Users/nagatyase/dmhtest/dist/"
)

const ()

var Cache *bigcache.BigCache

func init() {
	Cache, _ = bigcache.NewBigCache(bigcache.DefaultConfig(10 * time.Minute))
}

func UnixNow() string {
	return strconv.Itoa(int(time.Now().Unix()))
}

func GetNowTime() string {
	now := time.Now()
	s := now.Format("2006-01-02 15:04:05")
	return s
}

func GetNowTimeYYYYMMDDhhmmss() string {
	now := time.Now()
	s := now.Format("20060102150405")
	return s
}
